package com.board.controller;


import cn.hutool.core.bean.BeanUtil;
import com.board.dto.OrderCommentDto;
import com.board.entity.OrderLog;
import com.board.form.FindOrderLogForm;
import com.board.param.FindOrderLogParam;
import com.board.service.OrderLogService;
import com.board.util.PageInfo;
import com.board.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 膳食系统-订单日志表 前端控制器
 * </p>
 *
 * @author 小叶
 * @since 2024年04月04日
 */
@RestController
@RequestMapping("/orderLog")
@Api(tags = "订单日志接口")
public class OrderLogController {
    @Autowired
    private OrderLogService orderLogService;

    /**
     * 根据id查询日志
     * @param logId 要查询的日志id
     * @return 返回查询的日志
     */
    @GetMapping("/findOrderLogById")
    @ApiOperation("id查询日志")
    public Result findOrderLogById(Integer logId){
        OrderLog orderLog= orderLogService.findOrderLogById(logId);
        return Result.success("根据id查询日志成功",orderLog);
    }

    /**
     * 条件查询日志
     * @param form 查询条件，包含订单类型、订单编号、操作人员
     * @return 返回查询的数据
     */
    @GetMapping("/findOrderLogByCondition")
    @ApiOperation("条件查询日志")
    public Result findOrderLogByCondition(FindOrderLogForm form){
        PageInfo<OrderLog> pageInfo= orderLogService.findOrderLogByCondition(BeanUtil.toBean(form, FindOrderLogParam.class));
        return Result.success("条件查询日志成功",pageInfo);
    }

}

